MODULE definitions
  !-----------------------------------------------------------
  ! Definitions for the KRUUNUNHAKA basis set tool kit
  !-----------------------------------------------------------
  ! See CHANGELOG
  !-----------------------------------------------------------
  ! Copyright (C) 2003-2008 Pekka Manninen, 2010 Jussi Lehtola
  !
  ! This program is distributed under the terms of the GNU General
  ! Public License as published by the Free Software Foundation;
  ! either version 2 of the License, or (at your option) any later version.
  !
  ! This program is distributed in the hope that it will be useful,
  ! but WITHOUT ANY WARRANTY; without even the implied warranty of
  ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  !
  ! Please note that this program as well as its 
  ! author must be properly cited whenever the program or some parts 
  ! originated on it are employed. 
  !
  !-----------------------------------------------------------

  IMPLICIT NONE
  INTRINSIC EPSILON, HUGE

  ! Double precision numbers
  INTEGER, PARAMETER :: prec = SELECTED_REAL_KIND(8)

  ! Value of pi
  REAL(KIND=prec), PARAMETER :: pi = 3.141592653589793_prec

  ! Number for extracting the values of epsilon and huge
  REAL(KIND=prec) :: testreal
  REAL(KIND=prec), PARAMETER :: epsi = EPSILON(testreal)
  REAL(KIND=prec), PARAMETER :: hug = HUGE(testreal)

  ! Convergence threshold for optimization
  REAL(KIND=prec), PARAMETER :: conv_thr = 1.0e-06

  !! Parameters for differential evolution optimization strategies
  ! Probability of pairing exponents together
  REAL(KIND=prec), PARAMETER :: evol_r = 0.1
  ! Strength of pairing
  REAL(KIND=prec), PARAMETER :: evol_c = 0.7
  ! Mutation parameters for exponents (scale up by noise_up, scale down by noise_low)
  REAL(KIND=prec), PARAMETER :: evol_up = 1.9, evol_low = 0.1
  ! Maximum allowed cost for eliminating pathogenic case
  REAL(KIND=prec), PARAMETER :: max_path = 0.8

  ! Number of points to calculate profile in in optimization routines
  ! (use odd number since integrals are evaluated with Simpson routine)
  INTEGER, PARAMETER :: optpoints = 401

  ! Maximum number of iterations
  INTEGER, PARAMETER :: maxit = 5000
  ! Printout every istep steps in full optimization
  INTEGER, PARAMETER :: istep = 25
  ! Printout every istep_even steps in even-tempered optimization
  INTEGER, PARAMETER :: istep_even = 2

  ! Population dimension - when optimizing nx exponents,
  ! amount of sets in population is nx*pop_dim
  INTEGER, PARAMETER :: pop_dim = 6

  ! Maximum line length when reading in files
  INTEGER, PARAMETER :: MAXLEN = 2500

  ! Terminal width
  INTEGER, PARAMETER :: TERMWIDTH = 80

  !! Angular momentum stuff
  ! Maximum angular momentum is l=6
  INTEGER, PARAMETER :: MAXL = 7 ! Account for Fortran indexing
  CHARACTER(LEN=1), DIMENSION(MAXL), PARAMETER :: &
       l_name = (/ 'S', 'P', 'D', 'F', 'G', 'H', 'I' /)
  ! If these are increased, also increase tablesize in overlap.c
END MODULE definitions
